unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Edit2: TEdit;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

const
  str = '1234567890abcdefghijkmnopqrstuvwxyxzABCDEFGHIJGMNOPQRSTUVWXYZ';
  str2 = 'fkBPcGXTs6VWpqY7JZhHigtCam38bjvGIeQr4dRnoN2wu0yx9MxzASOD1EF5U';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  str3: string;
  i, index: Integer;
  tmp: string;
begin
  tmp := Edit1.Text;
  for i := 1 to Length(tmp) do
  begin
    index := Pos(tmp[i], str2);
    if index > 0 then
    begin
      str3 := str3 + str[index];
    end
    else
    begin
      str3 := str3 + '?';
    end;
  end;

  Edit2.Text := str3;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  str3: string;
  i, index: Integer;
  tmp: string;
begin
  tmp := Edit2.Text;
  for i := 1 to Length(tmp) do
  begin
    index := Pos(tmp[i], str);
    if index > 0 then
    begin
      str3 := str3 + str2[index];
    end
    else
    begin
      str3 := str3 + '?';
    end;
  end;

  Edit1.Text := str3;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  strOrg: string;
  buff:array of byte;
  i,k:integer;
begin
  strOrg := Edit1.Text;
  k := length(strOrg);
  setlength(buff, k);
  Move(strOrg[1],buff[0],k);

  for i:= 0 to k-1 do
  begin
    buff[i] := buff[i] - 3;
  end;

  Edit2.Text := strpas(pansichar(@buff[0]));
end;

procedure TForm1.Button4Click(Sender: TObject);
var
  strOrg: string;
  buff:array of byte;
  i,k:integer;
begin
  strOrg := Edit2.Text;
  k := length(strOrg);
  setlength(buff, k);
  Move(strOrg[1],buff[0],k);

  for i:= 0 to k-1 do
  begin
    buff[i] := buff[i] + 3;
  end;

  Edit1.Text := strpas(pansichar(@buff[0]));
end;

end.
